<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: RCapture::CaptureStatus [RDoc Documentation]</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;

    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }

  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )

  // ]]>
  </script>

</head>
<body>


    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">RCapture::CaptureStatus</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>


                <a href="../../files/rcapture/capture_status_rb.html">

                rcapture/capture_status.rb

                </a>


        <br />

            </td>
        </tr>


        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>

                Object

            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">

  <div id="contextContent">

    <div id="description">
      <p>
Stack-based boolean enabled/disabled status. <a
href="CaptureStatus.html">CaptureStatus</a> is used to disable capturing
from within callbacks which could otherwise lead to infinite recursion or
undesired results.
</p>

    </div>

   </div>


    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">

        <a href="#M000008">current</a>&nbsp;&nbsp;

        <a href="#M000007">new</a>&nbsp;&nbsp;

        <a href="#M000012">off?</a>&nbsp;&nbsp;

        <a href="#M000011">on?</a>&nbsp;&nbsp;

        <a href="#M000013">restore</a>&nbsp;&nbsp;

        <a href="#M000010">set</a>&nbsp;&nbsp;

        <a href="#M000009">use</a>&nbsp;&nbsp;

      </div>
    </div>

  </div>

    <!-- if includes -->

    <div id="section">




    <!-- if method_list -->

    <div id="methods">

      <h3 class="section-bar">Public Class methods</h3>


      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">

          <a href="#M000008" class="method-signature">

          <span class="method-name">current</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Access thread-local capture status variable
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 17</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-constant">CaptureStatus</span>.<span class="ruby-identifier">current</span>
      <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:capture_status</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">CaptureStatus</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">true</span>)
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">

          <a href="#M000007" class="method-signature">

          <span class="method-name">new</span><span class="method-args">(value = true)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 11</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">true</span>)
      <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">value</span>
      <span class="ruby-ivar">@stack</span> = []
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <h3 class="section-bar">Public Instance methods</h3>


      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">

          <a href="#M000012" class="method-signature">

          <span class="method-name">off?</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Query status
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 43</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">off?</span>
      <span class="ruby-operator">!</span><span class="ruby-ivar">@status</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">

          <a href="#M000011" class="method-signature">

          <span class="method-name">on?</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Query status
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 38</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on?</span>
      <span class="ruby-ivar">@status</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">

          <a href="#M000013" class="method-signature">

          <span class="method-name">restore</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Pop status from stack
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 48</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore</span>
      <span class="ruby-ivar">@status</span> = <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">

          <a href="#M000010" class="method-signature">

          <span class="method-name">set</span><span class="method-args">(value)</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Set/push new status
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000010-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 32</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">value</span>)
      <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-ivar">@status</span>
      <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">value</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">

          <a href="#M000009" class="method-signature">

          <span class="method-name">use</span><span class="method-args">(value) {|| ...}</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Status is set to <tt>value</tt> while operating on the block.
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/capture_status.rb, line 22</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use</span>(<span class="ruby-identifier">value</span>)
      <span class="ruby-keyword kw">begin</span>
        <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">value</span>)
        <span class="ruby-keyword kw">yield</span>
      <span class="ruby-keyword kw">ensure</span>
        <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">restore</span>
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>



    </div>




  </div>

<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>
